import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'Login',
      component: () => import('@/views/auth/Login.vue'),
      meta: {
        title: '登录',
        icon: 'Login',
      }
    },
    {
      path: '/register',
      name: 'Register',
      component: () => import('@/views/auth/Register.vue'),
      meta: {
        title: '注册',
        icon: 'Register',
      }
    },
    {
      path: '/',
      // name: 'Main',
      component: () => import('@/layouts/MainLayout.vue'),
      redirect: '/login',
      children: [
        {
          path: 'dashboard',
          name: 'Dashboard',
          component: () => import('@/views/dashboard/Dashboard.vue'),
          meta: {
            title: '仪表盘',
            icon: 'Dashboard'
          }
        },
        {
          path: 'users',
          name: 'UserManagement',
          redirect: '/users/list',
          children: [
            {
              path: 'list',
              name: 'UsersList',
              component: () => import('../views/users/UsersList.vue')
            },
            {
              path: 'profile',
              name: 'UsersProfile',
              component: () => import('../views/users/UsersProfile.vue')
            }
          ]
        },
        {
          path: 'permissions',
          name: 'PermissionsManagement',
          redirect: '/permissions/roles',
          children: [
            {
              path: 'roles',
              name: 'PermissionsRoles',
              component: () => import('../views/permissions/PermissionsRoles.vue')
            },
            {
              path: 'menus',
              name: 'PermissionsMenus',
              component: () => import('../views/permissions/PermissionsMenus.vue')
            },
          ]
        },
        {
          path: 'content',
          name: 'ContentManagement',
          redirect: '/content/articles',
          children: [
            {
              path: 'articles',
              name: 'ContentArticles',
              component: () => import('../views/content/ContentArticles.vue')
            },
            {
              path: 'files',
              name: 'ContentFiles',
              component: () => import('../views/content/FileManagement.vue')
            }
          ]
        },
        {
          path: 'system',
          name: 'SystemManagement',
          redirect: '/system/logs',
          children: [
            {
              path: 'logs',
              name: 'SystemLogs',
              component: () => import('../views/system/SystemLogs.vue')
            }
          ]
        },
      ]
    },
  ],
})

export default router
